<?php

/**
 * @file
 * Path generation for Apache Solr Search.
 *
 * Available vars:
 * $keywords: user input
 * $types: content types (machine names[])
 * $terms: taxonomy terms (tids[])
 * $keys: complete search phrase, as core would have done it
 *
 * To return:
 * the complete search path
 *
 */

function _custom_search_apachesolr_search($variables) {
  $type = 'search/apachesolr_search/' . $variables['keywords'];
  $keys = array();

  if (count($variables['types']) && !in_array('all', $variables['types'])) $keys[] = 'bundle:' . implode(' bundle:', $variables['types']);

  if (module_exists('taxonomy') && count($variables['terms'])) $keys[] = 'tid:' . implode(' tid:', $variables['terms']);

  $keys = array('filters' => implode(' ', $keys));

  return array('path' => $type, 'query' => $keys);
}